<?php
/**
 *
 * @category   babel 
 * @package    BABEL
 * @author     Hannes Magnusson <hannes.magnusson@gmail.com>
 * @copyright  2008 Team babel
 * @license    LGPL
 */

class BabelZipArchive extends ZipArchive implements Iterator {
	private $idx = 0;
	public function __construct($filename, $flags = null) {
		if (true !== ZipArchive::open($filename, $flags)) {
			throw new Exception("Unknown fileformat");
		}
	}
	public function current() {
		return BabelLanguageFile::createFile($this->getStream($this->meta["name"]));
	}
	public function key() {
		return $this->meta["name"];
	}
	public function valid() {
		do {
			$meta = $this->statIndex($this->idx);
			if (!is_array($meta)) {
				return false;
			}
			if (substr($meta["name"], -4) === ".xml") {
				$this->meta = $meta;
				return true;
				continue;
			}
			$this->next();
		} while(true);

		return $bool;
	}
	public function next() {
		++$this->idx;
	}
	public function rewind() {
		$this->idx = 0;
	}
}

